package com.readbook.action;


import com.readbook.service.XsycService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Controller
@RequestMapping("/xsyc")
public class xsyc {
    @Resource
    private XsycService xsycService;


    @RequestMapping("Search_bookxsyc.html")
    @ResponseBody
    public Map<String, Object> Search_bookxsyc(HttpServletRequest request, HttpServletResponse response) {
        String nj = "";
        if (request.getParameter("nj") != null) {
            nj = request.getParameter("nj").toString().trim();
        }

        String bj = "";
        if (request.getParameter("bj") != null) {
            bj = request.getParameter("bj").toString().trim();
        }

        String sname = "";
        if (request.getParameter("sname") != null) {
            sname = request.getParameter("sname").toString().trim();
        }

        String zpmc = "";
        if (request.getParameter("zpmc") != null) {
            zpmc = request.getParameter("zpmc").toString().trim();
        }

        String bstate = "";
        if (request.getParameter("bstate") != null) {
            bstate = request.getParameter("bstate").toString().trim();
        }

        Map<String, Object> gmap = new HashMap<String, Object>();
        gmap.put("nj", nj);
        gmap.put("bj", bj);
        gmap.put("sname", sname);
        gmap.put("zpmc", zpmc);
        gmap.put("bstate", bstate);

        List<Map<String, Object>> list1 = xsycService.Search_bookxsyc(gmap);
        Map<String, Object> rmap = new HashMap<String, Object>();
        rmap.put("data", list1);
        return rmap;
    }


    /**
     * @author 牟明艳
     * @comments 审核原创
     * @time 2019年9月6日16:09:50
     */
    @RequestMapping("setshzt_xsyc.html")
    @ResponseBody
    public boolean setshzt_xsyc(HttpServletRequest request, HttpServletResponse response) {
        String sh = request.getParameter("sh").toString().trim();
        String ycid = request.getParameter("ycid").toString().trim();
        Map<String, Object> gmap = new HashMap<String, Object>();
        gmap.put("sh", sh);
        gmap.put("ycid", ycid);
        int i = xsycService.setshzt_xsyc(gmap);
        if (i > 0) {
            return true;
        } else {
            return false;
        }
    }


    /**
     * @author 牟明艳
     * @comments 删除学生原创
     * @time 2019年10月21日15:10:02
     */
    @RequestMapping("del_bookxsyc.html")
    @ResponseBody
    public Map<String, Object> del_bookxsyc(HttpServletRequest request, HttpServletResponse response) {
        String ycid = request.getParameter("ycid").toString().trim();
        Map<String, Object> gmap = new HashMap<String, Object>();
        gmap.put("ycid", ycid);
        int i = xsycService.del_bookxsyc(gmap);
        Map<String, Object> rmap = new HashMap<String, Object>();
        if (i > 0) {
            rmap.put("result", true);
            rmap.put("msg", "删除成功!");
            return rmap;
        }
        rmap.put("result", false);
        rmap.put("msg", "删除失败,请联系管理员");
        return rmap;
    }
}
